home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu017.dms / pu017.adf / Graphics / Example3.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  4KB  |  112 lines

  1. /* Example3                                                         */
  2. /* This program will open a normal window which is connected to the */
  3. /* Workbench Screen. We will then print a text string whith help of */
  4. /* Intuition's IntuiText structure.                                 */
  5.  
  6.  
  7.  
  8. /* If your program is using Intuition you should include intuition.h: */
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14.  
  15.  
  16.  
  17. /* Declare a pointer to a Window structure: */ 
  18. struct Window *my_window;
  19.  
  20. /* Declare and initialize your NewWindow structure: */
  21. struct NewWindow my_new_window=
  22. {
  23.   40,            /* LeftEdge    x position of the window. */
  24.   20,            /* TopEdge     y positio of the window. */
  25.   400,           /* Width       400 pixels wide. */
  26.   150,           /* Height      150 lines high. */
  27.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  28.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  29.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  30.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  31.   WINDOWDRAG|    /*             Drag gadget. */
  32.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  33.   ACTIVATE,      /*             The window should be Active when opened. */
  34.   NULL,          /* FirstGadget No Custom Gadgets. */
  35.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  36.   "TEXT",        /* Title       Title of the window. */
  37.   NULL,          /* Screen      Connected to the Workbench Screen. */
  38.   NULL,          /* BitMap      No Custom BitMap. */
  39.   0,             /* MinWidth    We do not need to care about these */
  40.   0,             /* MinHeight   since we have not supplied the window */
  41.   0,             /* MaxWidth    with a Sizing Gadget. */
  42.   0,             /* MaxHeight */
  43.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  44. };
  45.  
  46.  
  47.  
  48. UBYTE my_text[]="This is the text that will be printed!";
  49.  
  50. struct IntuiText my_intui_text=
  51. {
  52.   1,         /* FrontPen, colour register 1. */
  53.   2,         /* BackPen, colour register 2. */
  54.   JAM2,      /* DrawMode, draw the characters with colour 1, on a colour */
  55.              /* 2 background. (White text on a black background) */ 
  56.   10, 20,    /* LeftEdge, TopEdge. */
  57.   NULL,      /* ITextFont, use default font. */
  58.   my_text,   /* IText, the text that will be printed. */
  59.              /* (Remember my_text = &my_text[0].) */
  60.   NULL,      /* NextText, no other IntuiText structures are connected. */
  61. };
  62.  
  63.  
  64.  
  65. main()
  66. {
  67.   /* Open the Intuition Library: */
  68.   IntuitionBase = (struct IntuitionBase *)
  69.     OpenLibrary( "intuition.library", 0 );
  70.   
  71.   if( IntuitionBase == NULL )
  72.     exit(); /* Could NOT open the Intuition Library! */
  73.  
  74.  
  75.  
  76.   /* We will now try to open the window: */
  77.   my_window = (struct Window *) OpenWindow( &my_new_window );
  78.   
  79.   /* Have we opened the window succesfully? */
  80.   if(my_window == NULL)
  81.   {
  82.     /* Could NOT open the Window! */
  83.     
  84.     /* Close the Intuition Library since we have opened it: */
  85.     CloseLibrary( IntuitionBase );
  86.  
  87.     exit();  
  88.   }
  89.  
  90.  
  91.  
  92.   /* Tell Intuition to print the text: */
  93.   PrintIText( my_window->RPort, &my_intui_text, 0, 0 );
  94.  
  95.  
  96.  
  97.   /* We have opened the window, and everything seems to be OK. */
  98.   /* Wait for 30 seconds: */
  99.   Delay( 50 * 30);
  100.  
  101.  
  102.  
  103.   /* We should always close the windows we have opened before we leave: */
  104.   CloseWindow( my_window );
  105.  
  106.  
  107.   
  108.   /* Close the Intuition Library since we have opened it: */
  109.   CloseLibrary( IntuitionBase );
  110.   
  111.   /* THE END */
  112. }